package nyu.edu.database.transaction;

import java.util.PriorityQueue;
import java.util.Queue;

import nyu.edu.database.operation.Operation;

public class Transaction {

	private final int transactionId;
	private final int startTime;
	private TransactionStatus status;
	private Queue<Operation> myQueue;

	public Transaction(int transactionId, int startTime) {
		super();
		this.transactionId = transactionId;
		this.startTime = startTime;
		this.status = TransactionStatus.UNSTARTED;
		myQueue = new PriorityQueue<Operation>();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + transactionId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Transaction other = (Transaction) obj;
		if (transactionId != other.transactionId)
			return false;
		return true;
	}

	/*****************************
	 * Begin Getters And Setters *
	 *****************************/
	public TransactionStatus getStatus() {
		return status;
	}

	public void setStatus(TransactionStatus status) {
		this.status = status;
	}

	public int getTransactionId() {
		return transactionId;
	}

	public int getStartTime() {
		return startTime;
	}

}
